//
// Created by 黄扬航 on 2023/4/19.
//

#include "Map.h"
#include "Control.h"
#include <stdlib.h>
#include <ctime>
#include "Tools.h"
#include<stdio.h>
Tools c;
Point::Item Point::PointItems[600] = {};
bool Point::ThereIsFood = false;
Point* Point::Pointer=NULL;
void Point::CreatFood()
{
    if (ThereIsFood)
        return;
    else
    {
        srand(time(NULL));
        while (true)
        {
            int FoodX = std::rand() % 55, FoodY = std::rand() % 8;
            const int Index = FoodX + MaxLength * (FoodY);
            if (PointItems[Index].IsSnake || PointItems[Index].IsBorder)
                continue;
            else
            {
                PointItems[Index].IsFood = true;
                c.MoveCursorTo(FoodX, FoodY, "F");
                ThereIsFood = true;
                FoodTarget.emplace(Index);
                return;
            }
        }
    }
}
